package com.example.czy.qo;

import com.example.czy.annotation.Query;
import com.example.czy.annotation.QueryOR;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author czy
 * @date 2023-07-09
 **/
@Data
public class GoodsQO {
    /**
     * 多表关联查询时可以使用别名 如：g.id
     * 默认查询类型为 equal
     * id =
     */
    @ApiModelProperty("商品Id")
    @Query(field = "g.id")
    private Long id;

    /**
     * like可以指定为：left like、like、right like
     * name like '1%'
     */
    @ApiModelProperty("商品名称")
    @Query(type = Query.Type.RIGHT_LIKE)
    private String name;

    /**
     * between 支持集合、数组、逗号分割
     * create_Time between '2021-07-09' and '2023-07-09'
     */
    @ApiModelProperty("商品创建时间区间逗号分割")
    @Query(field = "g.createTime", type = Query.Type.BETWEEN)
    private String createTime;

    /**
     * 多字段模糊匹配，适合一键搜索场景
     * (name like '%1%' or description like '%1%')
     */
    @ApiModelProperty("商品或描述")
    @Query(likes = "name,description")
    private String keyword;

    /**
     * 嵌套查询注解@QueryOR 相当于 and (store_id is not null or goods_id is not null)
     */
    @QueryOR
    private StoreQO storeQO;

    /**
     * 排序如：createTime desc,id
     * (order by create_time desc,id asc)
     */
    @ApiModelProperty("排序，逗号分割")
    private String sort;
}
